<:!:/>

@file c.search.html
@author Alejandro Dario Simi
@date $Date: 2013-05-24 23:14:00 +0000 (Fri, 24 May 2013) $

$Id: c.search.html 66 2013-05-24 23:14:00Z daemonraco@gmail.com $
$URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0-BETA1/themes/default/templates/contents/c.search.html $

<::/><script type="text/javascript">
	var	ANIMATION_RUNNING	= false;
	var	PREVIEWS		= new Array();
	var	MULTI_PREVIEWS		= new Array();
	var	WORDS			= new Array();

	<:OVER:list=SEARCH-WORDS:key=word:/>WORDS.push('<:VAR:/>word<::/>');
	<::/>
	function animatePreview(id, pos) {
		if(ANIMATION_RUNNING == id && MULTI_PREVIEWS[id].length > 0) {
			if(pos > (MULTI_PREVIEWS[id].length-1)) {
				pos = 0;
			}

			$("#SrchPreview_"+id).attr("src", MULTI_PREVIEWS[id][pos]);
			pos++;
			setTimeout("animatePreview('"+id+"', "+pos+");", 500);
		}
	}
	function animatePreviewsOf(id) {
		ANIMATION_RUNNING = id;
		animatePreview(id, 0);
	}
	function retorePreviewsOf(id) {
		ANIMATION_RUNNING = false;
		$("#SrchPreview_"+id).attr("src", PREVIEWS[id]);
	}
	function markFindings() {
		if(WORDS.length > 0) {
			$(".SearchWords").each(function(){
				var	out	= $(this).text();
				var	str	= out.toLowerCase();
				var	offset	= 0;

				var	offsets	= new Array();
				var	lengths	= new Array();

				for(var word in WORDS) {
 					while(offset < str.length) {
						offset = str.indexOf(WORDS[word], offset);
						if(offset > 0) {
							offsets.push(offset);
							lengths.push(WORDS[word].length);
						} else {
							break;
						}
						offset++;
					}
				}

				if(offsets.length > 0) {
					offset	= 0;
					str	= out;
					out	= "";
					for(var idx in offsets) {
						if(offsets[idx] > offset) {
							out += str.substr(offset, offsets[idx]-offset);

							out += '<span class="Match">';
							out += str.substr(offsets[idx], lengths[idx]);
							out += '</span>';

							offset = offsets[idx] + lengths[idx];
						}
					}
					if(offset < str.length) {
						out += str.substr(offset);
					}

					$(this).html(out);
				}
			});
		}
	}

	$(function(){
		markFindings();
	});
</script>

<table class="SeachContent">
	<tr>
		<td><form class="Formulary" action="#" method="GET">
			<input type="hidden" name="action" value="<:VAR:/>WC_ACTION_SEARCH<::/>"/>
			<input type="hidden" name="group"  value="<:VAR:/>GROUP-ID<::/>"/>
			<table><tr>
				<td class="Label">Words</td>
				<td class="Value"><input class="Full" type="text" id="pattern" name="pattern" value="<:VAR:!:/>search-pattern<::/>"/></td>
			</tr><tr>
				<td class="Label">Exceptions</td>
				<td class="Value"><input class="Full" type="text" id="exceptions" name="exceptions" value="<:VAR:!:/>search-exceptions<::/>"/></td>
			</tr><tr>
				<td class="Label">Types</td>
				<td class="Value">
					<div class="Block">
						<input type="checkbox" id="O-CL" name="O-CL"<:ISSET:var=O-CL:/> checked="checked"<::/>/><label for="O-CL">Only Collections</label>
					</div>
					<div class="Block">
						<input type="checkbox" id="O-TA" name="O-TA"<:ISSET:var=O-TA:/> checked="checked"<::/>/><label for="O-TA">Only Tags</label>
					</div>
					<div class="Block">
						<input type="checkbox" id="O-DI" name="O-DI"<:ISSET:var=O-DI:/> checked="checked"<::/>/><label for="O-DI">Only Directorires</label>
					</div>
					<div class="Block">
						<input type="checkbox" id="O-CX" name="O-CX"<:ISSET:var=O-CX:/> checked="checked"<::/>/><label for="O-CX">Only Comics</label>
					</div>
					<div class="Block">
						<input type="checkbox" id="O-RL" name="O-RL"<:ISSET:var=O-RL:/> checked="checked"<::/>/><label for="O-RL">Only Rules</label>
					</div>
				</td>
			</tr><tr>
				<td class="Label">Results</td>
				<td class="Value"><:VAR:!:/>result-count<::/> items</td>
			</tr><tr>
				<td class="Label">Times</td>
				<td class="Value"><ul>
					<li>Elapsed: <:VAR:!:/>time-elapsed<::/> ms</li>
					<li>Search: <:VAR:!:/>time-search<::/> ms</li>
					<li>2nd layer: <:VAR:!:/>time-secondlayer<::/> ms</li>
					<:ISSET:var=time-filter:/><li>Filtering: <:VAR:!:/>time-filter<::/> ms</li><::/>
					<li>Build: <:VAR:!:/>time-build<::/> ms</li>
				</ul></td>
			</tr><tr>
				<td class="Label"></td>
				<td class="Value"></td>
			</tr><tr>
				<td class="Label"></td>
				<td class="Value"></td>
			</tr><tr>
				<td class="Label"></td>
				<td class="Value"></td>
			</tr><tr>
				<td class="Buttons" colspan="2"><input type="submit" value="Search"/></td>
			</tr></table>
		</form></td>
	</tr>
	<tr><td class="SeachItems">
		<:OVER:list=search-items:/><script type="text/javascript">
				PREVIEWS['<:VAR:/>id<::/>'] = "<:VAR:/>preview<::/>";
				MULTI_PREVIEWS['<:VAR:/>id<::/>'] = new Array();
				<:OVER:list=previews:key=img:/>MULTI_PREVIEWS['<:VAR:/>id<::/>'].push('<:VAR:/>img<::/>');
				<::/>
			</script>
			<a href="<:VAR:/>link<::/>"
				onMouseOver="animatePreviewsOf('<:VAR:/>id<::/>');" onMouseOut="retorePreviewsOf('<:VAR:/>id<::/>');">
				<table class="SeachItem"><tr>
					<td class="Preview" rowspan="2">
						<img id="SrchPreview_<:VAR:/>id<::/>" src="<:VAR:/>preview<::/>"/>
					</td>
				</tr><tr>
					<td class="Information">
						<:!:/><:ISSET:var=factor:/><div class="Factor">Factor: <:VAR:/>factor<::/></div><::/><::/>
						<:ISSET:var=hits:/><div class="Hits">Factor: <:VAR:/>factor<::/></div><::/>
						<div class="Name">Name: <span class="SearchWords"><:VAR:/>name<::/></span></div>
						<:!:/><div class="FullName">Full Name: <:VAR:/>full-name<::/></div><::/>
						<div class="Type">Type: <:VAR:/>type<::/></div>
						<:ISSET:var=count:/><div class="Count">Count: <:VAR:/>count<::/></div><::/>
					</td>
				</tr></table>
			</a><::/>
	</td></tr>
</table>
<:INCLUDE:padding=0:/>/generics/pager.html<::/>
